package com.scs.application.modules.dept.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.scs.application.core.mapper.IBaseMapper;
import com.scs.application.modules.dept.entity.UseDtl;
import com.scs.application.modules.wm.dto.StockHisPushDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 */
public interface UseDtlMapper extends IBaseMapper<UseDtl> {
    IPage<UseDtl> pageForRedList(IPage page, @Param(Constants.WRAPPER) QueryWrapper wrapper, @Param("params") Map<String, Object> params);

    List<UseDtl> getUseDtlBySn(@Param("sn") String sn, @Param("warehouseId") String warehouseId);

    /**
     * 查询科室消耗单明细下的耗材分类
     */
    @Select("select m.base_type from base_matr m inner join dept_use_dtl t on m.id = t.matr_id where t.use_id = #{useId} group by m.base_type")
    List<String> getType(@Param("useId") String useId);

    /**
     * 删除科室消耗单明细
     */
    int removeByStockIds(@Param("stockIds") List<String> stockIds, String useId);

    //获取需要推送给HIS的库存
    List<StockHisPushDTO> getListForHisPush();
}
